//
//  DataView.m
//  LiveSoftware
//
//  Created by lanou3g on 15/7/17.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//


#import "DataView.h"

#define kTitleY kScreenIp6(20)
#define kBtnWidth kScreenIp6(60)
#define kBtnHeight kScreenIp6(40)

@interface DataView ()

@end

@implementation DataView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addBackImageView];
        
        CGFloat baseScrollViewH = kScreenHeight - kScreenIp6(109) - 48;
        self.baseScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, kScreenIp6(109), kScreenWidth, baseScrollViewH)];
        _baseScrollView.contentSize = CGSizeMake(kScreenWidth * 3, 0);
        self.baseScrollView.backgroundColor = [UIColor clearColor];
        [self addScrollView];
        
        self.teamOrderBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        self.teamOrderBtn.frame = CGRectMake(0, kScreenIp6(64), kScreenWidth / 3, kScreenIp6(46));
        self.teamOrderBtn.userInteractionEnabled = YES;
        [self.teamOrderBtn setTitle:@"积分榜" forState:UIControlStateNormal];
        [self.teamOrderBtn setTintColor:[UIColor whiteColor]];
        [self.backImageView addSubview:_teamOrderBtn];
        
        self.scoreOrderBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        self.scoreOrderBtn.frame = CGRectMake(kScreenWidth / 3, kScreenIp6(64), kScreenWidth / 3, kScreenIp6(46));
        self.scoreOrderBtn.userInteractionEnabled = YES;
        [self.scoreOrderBtn setTitle:@"射手榜" forState:UIControlStateNormal];
        [self.scoreOrderBtn setTintColor:[UIColor colorWithWhite:0.900 alpha:1.000]];
        [self.backImageView addSubview:_scoreOrderBtn];
        
        self.assistOrderBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        self.assistOrderBtn.frame = CGRectMake(kScreenWidth * 2 / 3,kScreenIp6(64), kScreenWidth / 3, kScreenIp6(46));
        [self.assistOrderBtn setTitle:@"助攻榜" forState:UIControlStateNormal];
        [self.assistOrderBtn setTintColor:[UIColor colorWithWhite:0.900 alpha:1.000]];
        [self.backImageView addSubview:_assistOrderBtn];
        
        
        self.pointImage = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.pointImage setImage:[UIImage imageNamed:@"point"] forState:UIControlStateNormal];
        self.pointImage.bounds = CGRectMake(0, 0, kScreenIp6(15), kScreenIp6(20));
        self.pointImage.center = CGPointMake(kScreenWidth/6, kScreenIp6(105));
        [self.pointImage setTintColor:[UIColor whiteColor]];
        [self.backImageView addSubview:_pointImage];
        
    }
    return self;
}

#pragma mark - 添加背景视图
- (void)addBackImageView
{
    self.backImageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.backImageView.image = [UIImage imageNamed:@"BackImage"];
    self.backImageView.userInteractionEnabled = YES;
    [self addSubview:self.backImageView];
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake((kScreenWidth - kBtnWidth) / 2, kTitleY, kBtnWidth, kBtnHeight)];
    self.titleLabel.font = [UIFont systemFontOfSize:18];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.textColor = [UIColor whiteColor];
    [self.backImageView addSubview:_titleLabel];
}

#pragma mark - 添加 ScrollView
- (void)addScrollView
{
    self.baseScrollView.contentOffset = CGPointMake(0, 0);
    self.baseScrollView.showsHorizontalScrollIndicator = YES;
    self.baseScrollView.bounces = NO;
    self.baseScrollView.pagingEnabled = YES;
    
    self.leftTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, self.baseScrollView.bounds.size.height)];
    self.leftTableView.backgroundColor = [UIColor clearColor];
    [self.baseScrollView addSubview:_leftTableView];

    
    self.centerTableView = [[UITableView alloc] initWithFrame:CGRectMake(kScreenWidth, 0, kScreenWidth, self.baseScrollView.bounds.size.height)];
    self.centerTableView.backgroundColor = [UIColor clearColor];
    [self.baseScrollView addSubview:_centerTableView];
    
    self.rightTableView = [[UITableView alloc] initWithFrame:CGRectMake(kScreenWidth * 2, 0, kScreenWidth, self.baseScrollView.bounds.size.height)];
    self.rightTableView.backgroundColor = [UIColor clearColor];
    [self.baseScrollView addSubview:_rightTableView];

    [self.backImageView addSubview:_baseScrollView];
}

@end
